home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4959 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.3 KB  |  54 lines

  1. Newsgroups: comp.lang.c++
  2. Path: rug.nl!root
  3. From: S.H.Grotenhuis@cpedu.rug.nl (Steven Grotenhuis)
  4. Subject: Re: BORLAND C++ 4.5 wont add .1 and .9
  5. Message-ID: <DM41Dn.4ty@rug.nl>
  6. Sender: root@rug.nl (Operator)
  7. Nntp-Posting-Host: slip.cpedu.rug.nl
  8. Organization: Rekencentrum der Rijksuniversiteit Groningen
  9. X-Newsreader: Forte Free Agent 1.0.82
  10. References: <corekinDLG8t4.3C5@netcom.com> <4e5njv$e9v@damon.irf.uni-dortmund.de>
  11. Date: Thu, 1 Feb 1996 18:39:00 GMT
  12.  
  13. Experimenting with this problem leaned me this:
  14.  
  15. #include <stdio.h>
  16. int one()
  17. { return 1;
  18. }
  19.  
  20. void main()
  21. {     int two;
  22.      int zero=0;
  23.      if (zero==0) {two=1+one();
  24.           //two=two;
  25.              }
  26.  
  27. /*apparently it's not just the ? operator
  28.   that causes trouble.
  29.   applying this dummy-statement causes BC4.5
  30.   to yield the expected result as well as replacing
  31.   two=1+one(); with two=1+one()+one();
  32. */
  33.  
  34.      else two=zero+1;
  35.  
  36. /*this is perhaps the strangest part of the
  37.   bug: omitting the else-statement or replacing
  38.   it by 'else two=zero+23;' or something also results
  39.   in the correct output, eventhough 'tracing into'
  40.   suggests that this statement is never reached.
  41. */
  42.  
  43.      printf("one() plus 1 is %d\n", two);
  44. }
  45.  
  46. Has anyone tried the Microsoft compilers yet ?
  47.  
  48. How about the certainty I relied on that malfunctioning programs are
  49. the programmer's responsability ?
  50. --
  51. Steven Grotenhuis
  52. Dauwtrappers inc.
  53.  
  54.